<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>读者管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出读者吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/book/reader/export");
						$("#searchForm").submit();
						$("#searchForm").attr("action","${ctx}/book/reader/list");
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true},
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
		});

		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
	</script>
</head>
<body>
<div id="importBox" class="hide">
	<form id="importForm" action="${ctx}/book/reader/import" method="post" enctype="multipart/form-data"
		  class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
		<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
		<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
		<a href="${ctx}/book/reader/import/template">下载模板</a>
	</form>
</div>
<ul class="nav nav-tabs">
	<li class="active"><a href="${ctx}/book/reader/list">读者列表</a></li>
	<li><a href="${ctx}/book/reader/form">读者添加</a></li>
</ul>
<form:form id="searchForm" modelAttribute="reader" action="${ctx}/book/reader/list" method="post" class="breadcrumb form-search ">
	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
	<ul class="ul-form">
		<li><label>读者姓名：</label>
			<form:input path="rdName" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li><label>借书证号：</label>
			<form:input path="rdCardno" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li><label>IC卡号：</label>
			<form:input path="rdIccardno" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li><label>年级/班级：</label>
			<form:select path="rdGrad" items="${fns:getSearchDictList('rd_Grad')}" itemLabel="label" itemValue="value" class="input-medium" />
		</li>
		<li><label>读者类型：</label>
			<form:select path="rdRoleId" items="${fns:getAllReadRoleList()}" itemLabel="roleName"
						 itemValue="rdRoleId" cssStyle="width: 180px;" class="input-medium"/>
		</li>
		<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/>
			<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
			<input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
		<li class="clearfix"></li>
	</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<thead>
	<tr>
		<th>读者编号</th>
		<th>读者姓名</th>
		<th>年级/科室</th>
		<th>借书证号</th>
		<th>IC卡号</th>
		<th>联系电话</th>
		<th>读者性别</th>
		<th>办证日期</th>
		<th>有效日期</th>
		<th>读者状态</th>
		<th>读者类型</th>
		<th>操作</th>
	</thead>
	<tbody>
	<c:forEach items="${page.list}" var="rdlist">
		<tr>
			<td>${rdlist.rdId}</td>
			<td>${rdlist.rdName}</td>
			<td>${fns:getDictLabel(rdlist.rdGrad, 'rd_Grad', '')}</td>
			<%--<td>${rdlist.rdGrad}</td>--%>
			<td>${rdlist.rdCardno}</td>
			<td>${rdlist.rdIccardno}</td>
			<td>${rdlist.rdTele}</td>
			<td>${fns:getDictLabel(rdlist.rdSex, 'sex', '男')}</td>
			<td><fmt:formatDate value="${rdlist.rdReg}" pattern="yyyy-MM-dd"/></td>
			<td><fmt:formatDate value="${rdlist.rdOver}" pattern="yyyy-MM-dd"/></td>
			<td>${fns:getDictLabel(rdlist.rdState, 'rdstatus', '正常')}</td>
			<td>${rdlist.roler.roleName}</td>
			<td>
				<a href="${ctx}/book/reader/form?id=${rdlist.rdId}">修改</a>
				<c:if test="${rdlist.rdState eq '0'}">
					<a href="${ctx}/book/reader/changestatus?id=${rdlist.rdId}&status=2" onclick="return confirmx('确认要挂失该用户吗？', this.href)">挂失</a>
					<a href="${ctx}/book/reader/changestatus?id=${rdlist.rdId}&status=1" onclick="return confirmx('确认要停用该用户吗？', this.href)">停用</a>
				</c:if>
				<a href="${ctx}/book/reader/delete?id=${rdlist.rdId}" onclick="return confirmx('确认要删除该用户吗？', this.href)">删除</a>
			</td>
		</tr>
	</c:forEach>
	</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>